NMEAconverter

../Images/opencpn_dev_plugins_plugins.png

../Images/opencpn_manual_plugins_nmeacon.jpg

NMEA Converter can convert incoming NMEA Sentences

Be aware you need at least some knowledge of NMEA Sentences

For Reference from the Nmea Sentences Page[1629]

Install the plugin in accord with the Install and Enable[1630] Instructions.

Then open the Preference Dialog to set your conversions.

../Images/opencpn_manual_nmea-converter.png

If you see something like above please enlarge the nmeaSendObjectDlg window so it will show some buttons.

1. First Test

../Images/opencpn_manual_testmessage1.png

This is a completely useless sentence that is sent every second to OpenCPN. Check also the nmeadebug window in the picture above, and note that a checksum is added to the sentence. It is easy to change this one into something like:

$GPRMC,085437,A,5324.3052,N,00611.5704,E,3.3,68.9,070614,0.3,E,A

Just enter this line into the NmeaConverter > Preference > New > Edit box and Save it. No VDR file is needed. That will fake a GPS position into OpenCPN, but still not very usefull.

2. Use incoming data to send a different NMEA sentence.

The real power of this plugin is that you can change the data of the sent sentence by cherry picking from incoming sentences. The reason I wrote this plugin was I wanted Dashboard to show the air temperature. To get the data, Dashboard needs a $xxMTA sentence, however I had a Airmar PB200 unit that is sending $xxMDA sentences.

An example: We have from the windset,

MDA- Meterological (Obsolete)

$WIMDA,30.1,I,1.0,B,11.3,C,,,,,,,18.6,T,18.5,M,5.8,N,3.0,M*27

and want: MDA- Air temperature

$xxMTA,11.3,C*<Checksum>

Note that the data needed is in fields 5 and 6 of the MDA sentence. (11.3 degrees Celcius)

Setting the format to

$XXMTA, $WIMDA5, $WIMDA6

will give an output sentence:

$XXMTA, 11.3, C*26

Where $WIMDA5 is replaced by the 5th field of the $WIMDA sentence. etc.

../Images/opencpn_manual_xxmtamessage2.png

As seen above, the $XXMTA sentece is sent each time a $WIMDA sentence is received and read by Dashboard.

For testing use VDR_pi or VDRplayer and run WIMDA+OCMDA.txt from this zip[1631]

3. Do math-Convert units, e.g. Centigrade to Fahrenheit

But what if I was living in the US and prefered the reading to be in degrees Fahrenheit? Just change the format to:

$XXMTA, 9/5*$WIMDA5 + 32, F

opencpn:manual:xxmtamessage3.png

The value is recalculated and displayed as degrees Fahrenheit.

Use the same file for testing use VDR_pi or VDRplayer and run WIMDA+OCMDA.txt from this zip[1632]

4. Force True Heading to COG

In NMEAconverter create a HDG (compass) sentence from your COG. Possible use when the autopilot is old and does not receive heading (true or magnetic).

Note: Since computation of the drift and surface current requires HDG, it is understood that while using Tactics_pi value for Current speed and direction will not be useful. All you will see is the speed difference between SOG and STW, which would force Current to be the vector component normal to the keel. That means the “current” display will always be directly from bow or stern, in other words the component of the current along the centerline of the boat, assuming your STW(speed through water) is calibrated correctly.

See CF Tactics_pi Post #22[1633].

opencpn:manual:aufnahme37.jpg

The nmea file being run by VDR_pi is vdr2 - copie.xls[1634]

Tactics_pi and in particular, NMEAconverter_pi is using

$XXHDT,$IIVTG1,$IIVTG2

Remember that setting HDT to COG will give you no drift angle at all (except maybe a small portion via the manual heel input), so you will not see any real current I suggest to set a fixed heel angle to 0 (see screenshot above), to avoid side effects with manual heel input at very low speeds and small speed differences between SOG and STW.

5. Calculate True Wind from Apparent Wind

Known

Boat Speed ground (kts) = SOG
Apparent wind speed (degrees) = AWS
Apparent wind angle (degrees) = AWA

MWV - Wind Speed and Angle - Input

$–MWV,x.x,a,x.x,a*hh<CR><LF>

Field Number:

  1. Wind Angle, 0 to 360 degrees
  2. Reference, R = Relative, T = True
  3. Wind Speed
  4. Wind Speed Units, K/M/N
  5. Status, A = Data Valid
  6. Checksum
$–RMA,A,llll.ll,a,yyyyy.yy,a,x.x,x.x,x.x,x.x,x.x,a*hh<CR><LF>

Field Number:

  1. Blink Warning
  2. Latitude
  3. N or S
  4. Longitude
  5. E or W
  6. Time Difference A, uS
  7. Time Difference B, uS
  8. Speed Over Ground, Knots
  9. Track Made Good, degrees true
  10. Magnetic Variation, degrees
  11. E or W
  12. Checksum

MWV - Wind Speed and Angle - Output TW in Knots

$–MWV,x.x,T,x.x,K*hh<CR><LF>

Field Number:

  1. Wind Angle, 0 to 360 degrees
  2. Reference, R = Relative, T = True
  3. Wind Speed
  4. Wind Speed Units, K/M/N
  5. Status, A = Data Valid
  6. Checksum

Nmea0183 from http://www.catb.org/gpsd/NMEA.html[1635]

Calculations Needed:


x =AWS*sin(AWA*3.14159265/180)
y =(x/tan(AWA*3.14159265/180)) - SOG
TWS (True Wind Speed) =x/sin(TWA*3.14159265/180)
TWA (True Wind Angle) =atan(x/y)*180/3.14159265
*Formula from http://www.bethandevans.com/calculators.htm[1636]

The formula now needs to be completed:
$XXMWV,

TWS and TWA

(From zzz, see zzz's Cruiser Forum Post[1637]

$XXMWV,$WIMWV1+acos((sqr($WIMWV3)+sqr($GPRMC7)+sqr($WIMWV3)-2*$GPRMC7*$WIMWV3*cos($WIMWV1*3.14159265/180)-sqr($GPRMC7))/(2*sqrt(sqr($GPRMC7)+sqr($WIMWV3)-2*$GPRMC7*cos($WIMWV1*3.14159265/180))*$WIMWV3)),T,sqrt(sqr($GPRMC7)+SQR($WIMWV3)-2*$GPRMC7*$WIMWV3*cos($WIMWV1*3.14159265/180)),N,A
  1. $s were missing in the previous version
  2. Changed wind speed unit from K to N
  3. Deleted spaces after commas.
  4. In terms of sog vs. stw, as pointed out, in most cases, diff is negligible I believe.
  5. One thing about stw is that the sensor cannot capture the movement of a vessel due to tide (as high as 5 knots!).
  6. For my purpose, gps is good enough.

Observations by Rhythm Doctor:

One needs to be careful with this calculation. There are at least two different syntaxes for the reporting of relative wind angle. The older VWR and VWT sentences for relative and true wind are not recommended for new devices, but there are many older devices and SeaTalk converters that still use them (specifically, my own instruments). The sentences look like this (with II talker ID in this example):

$IIVWR,084.0,R,10.4,N,5.4,M,19.3,K 
$IIVWT,084.0,R,10.4,N,5.4,M,19.3,K

1 084.0 Wind Angle 0 - 180
2 R Right of vessel heading (L = Left)
3 10.4 Wind Speed
4 N Wind Speed units Knots
5 5.4 Wind Speed
6 M Wind Speed units Metres per second
7 19.3 Wind Speed
9 K Wind Speed units Km/Hr

Newer devices use the preferred MWV sentence structure that looks like this (with II talker ID in this case):

$IIMWV,084.0,R,10.4,N,A
$IIMWV,084.0,T,10.4,N,A

1 084.0 Wind Angle 0 - 359
2 R Relative (T = True)
3 10.4 Wind Speed
4 N Wind Speed units Knots (K = KPH, M = MPH)
5 A Status (A= Valid)

Note that VWR/VWT and MWV work totally differently: VWR provides wind angles from 0-180 with an additional parameter of L or R, while MWV provides wind angles from 0-359 with no L or R. Converting your obsolete VWR sentence to the more modern MWV sentence would seem to be impossible without a conditional if() statement, which appears to not be supported (since I was unable to get it to work).

Here is the sentence that works best for me for converting VWR (relative/apparent wind) to VWT (true wind). Using the wildcard (instead of II, GP, or WI sender IDs) allows testing with others' VWR sentences, including Paul Elliot's test nmea files:

$XXVWT,90-deg(atan(($??VWR3*cos(rad($??VWR1))-$??RMC7)/$??VWR3*sin(rad($??VWR1)))),$??VWR2,sqrt(sqr($??VWR3*sin(rad($??VWR1)))+sqr($??VWR3*cos(rad($??VWR1))-$??RMC7)),$??VWR4,,,,

Note that there is an invisible <return> character at the end of this sentence (after the four commas). In my testing, things don't work right without it. I recommend that you include it if you copy/paste this formula into the config dialog.

Transmitter Dan advises:

It is possible to replace the sender ID (GP or WI) with ?? which means any sender ID will be accepted. Using the wildcard will allow Paul Elliot's test nmea file to work with the nmeaconverter formula, using Seatalk - vYacht dialect:

$XXMWV,90-deg(atan(($??MWV3*cos(rad($??MWV1))-$GPRMC7)/$??MWV3*sin(rad($??MWV1)))),T,sqrt(sqr($??MWV3*sin (rad($??MWV1)))+sqr($??MWV3*cos(rad($??MWV1))-$GPRMC7)),N,A

Edit: In above formula's 3.14159265 might be replaced by “pi”, and 3.14159265/180 can also be written as “deg”.

Paul Elliot's Test Files[1638]

7. Prepare Barometer Sensor Output for Dashboard

Aim

The BMP180 pressure sensor output from Raspberry Pi/OpenPlotter uses the sentence $OSXDR. This cannot be read by Dashboard. BMP180 Output Units are Bars i.e 1000 times the reading needed for display - mBar/hectoPascal. Any error in the output cannot be corrected. This formula creates an $xxMDA (deprecated) or $xxXDR sentence that can be used by Dashboard.

Conversion

$MYXDR,P, 0.018 + 1/1000 * $OSXDR2,B,Barometer

Deprecated:

$MYMDA, , ,0.018 +1/1000*$OSXDR2,,B,,,,,,,,,,,,,,,,M

(0.018 is an error correction and also adjusts the barometer pressure for a sea level reading)

Applying the settings

Found it necessary to tick the 'block incomming (sic) messages with wrong checksum' box when editing the sentence.

../Images/opencpn_dev_plugins_beta_plugins_plugins_under_development_block_incomming.png

When editing the sentence; starting a variable with '.' or '$' causes OpenCPN to freeze. Variables are being read by the plugin all the time and these characters are not recognised. Workaround is to type '0.' and then the number. Also 'OSXDR2' and then add the '$' in front, '$OSXDR2'.

../Images/opencpn_dev_plugins_beta_plugins_plugins_under_development_osxdr_variables.png

../Images/opencpn_dev_plugins_beta_plugins_plugins_under_development_virtual_mda.png

8. Fix incorrect ST60 Wind Speed Data

Ratsea has fixed an incorrect Raymarine ST60 conversion.

Problem

Dashboard displays incorrect wind speed data when using the ST60 Multi NMEA Output. The data is treated as Km/hr as it has the K unit identifier and is converted to knots/m per sec/Km/hr as per the Dashboard settings, it then incorrect as the data is already in Knots

Aim

Change the display units in the wind output sentence from ST60 Multi from K (kms/hr) to N (kts) as the Raymarine instrument incorrectly uses the K identifier for Knots and not the N, so that the Dashboard correctly displays the Wind Speed data in the units selected.

Process

Using the NMEA converter, apply the conversion to the MWV sentence with a new ID - xx:

$xxMWV,$IIMWV1,$IIMWV2,$IIMWV3,N,$IIMWV5

and tick 'Send after update all variable' With the instrument switched on and receiving the actual live data shows in Blue.

../Images/opencpn_manual_plugins_nmea-con-st60.jpg

The NMEA datastream then becomes:

$IIHDM,143,M*3A
$IIMTW,025.2,C*26
$IIMWV,155,R,009.0,K,A*2E Input
$xxMWV,155,R,9.0,N,A*2B Corrected, the input line is also shown on the dashboard, but too quickly to notice
$IIVHW,,T,143,M,00.00,N,00.00,K*63

Caution

Whilst developing this code, I found that using the formula:

$IIMWV,$IIMWV1,$IIMWV2,$IIMWV3,N,$IIMWV5 

would also work if the 'Send every (n) seconds' was ticked, but the Dashboard would flash between the two values of Km/sec and knots. If the Send after update all… was ticked, then OpenCPN would freeze in a continuous loop trying to update the newly created NMEA sentence!

9. Use Wildcards

Now it is possible to use wildcards in the identifiers. So you could make it talkerid independent by using something similar to

.....$??XXX3....

and whatever character on the ? position will cause a hit.

Even more important, you might use it for special transducers sending the something like

$OWXDR,H,....or $OWXDR,C....

sentence.

Note that field 1 is part of the identifier. As the comma is the nmea separator, you can not use it as an identifier string, but by using a wildcard it works.

For example

 ....$OWXDR?H2... or $??XDR?H2....

will work.

10. Convert Temperature C to Farenheit

Using convert C to F for temp ( $XXMTA, 9/5*$AIMTW5 + 32, F) with send after all updates variables checked.

You are using an ..MTW sence. Format according my info:

$–MTW,x.x,C_hh

 $XXMTA, 9/5*$AIMTW1 + 32, F

Used new formula provided above.. Still Crashed. I removed the

$Dummy

entry that came with NmeaConverter_pi install. OpenCPN no longer crashes with NmeaConverter_pi enabled with a NMEA stream present..and as provided for above

$XXMTA, 9/5*$AIMTW1 + 32, F

is showing the “Air Temp” in F in Dasboard on O. “I can never thank the volunteers enough for all these wonderful tools.”

11. Contribute your Formulas & Conversions

If you have an useful format formula please feel free to add it here.

Another future possibility is to do a comparison lookup of a boat''s Polar data and send a special NMEA sentence of the comparative result to the Dashboard using a special dedicated performance instrument, for example.

Calculations Supported

For calculations the following functions are suported:

Normal functions

abs : the absolute value, it removes the sign
ceil : the smallest integer greater than or equal to x
cub : x^3, safe way to compute such an exponent
deg : converts from radian to degree
exp : the exponential value
hvi : Heaviside's function, =0 if x<0, =1 if x>=0
int : the largest integer less than or equal to x
inv : inverts, 1/x
floor : not supported, see int
ln : the neperian logarithm
lnep : see ln
log : the logarithm base 10
rad : converts from degree to radian
sgn : the sign, -1 or +1. Zero returns +1.
sqr : x^2, safe way to compute such an exponent
sqrt : the root square
pi : 3.14159265
deg : 3.14159265/180

Trigonometric functions

acos : the secant (inverse of cosine)
acsh : the inverse of the hyperbolic cosine
asin : the cosecant (inverse of sine)
asnh : the inverse of the hyperbolic sine
atan : the cotangent (inverse of tangent)
atnh : the inverse of the hyperbolic tangent
cos : the cosine
cosh : the hyperbolic cosine
sin : the sine
sinc : the cardinal sine (radian)
sinh : the hyperbolic sine
tan : the tangent
tanh : the hyperbolic tangent

This makes it possible to do spreadsheet-like calculations. And as in a spreadsheet the trigonometric functions use radians.

In beta at this moment: